草庐IT

c++ - Visual Studio 和 Boost::Test

全部标签

c++ - 如何使用 tmpfile () 获取临时文件名

这个问题在这里已经有了答案:Isthereawaytogetthefilenamefroma`FILE*`?[duplicate](2个答案)关闭6年前。tmpfile()函数说:Thetemporaryfilecreatedisautomaticallydeletedwhenthestreamisclosed(fclose)orwhentheprogramterminatesnormally.Iftheprogramterminatesabnormally,whetherthefileisdeleteddependsonthespecificsystemandlibraryimple

c++ - 如何修复 distcc 错误

我正在尝试让distcc在两台机器CLIENT和SERVER之间工作,我“认为”我已经正确设置了它,但我仍然收到此错误(dcc_build_somewhere)Warning:failedtodistribute,runninglocallyinstead服务器上没有编译。我的配置如下CLIENT=192.168.0.14SERVER=192.168.0.15服务器上的/etc/default/distccSTARTDISTCC="true"ALLOWEDNETS="192.168.0.0/24"//AlsotriedCLIENTIPhereLISTENER="192.168.0.15

c++ - boost 异步读/写失败, "Insufficient system resources exist to complete the requested service"

我(貌似)随机收到错误:"Insufficientsystemresourcesexisttocompletetherequestedservice"当使用boost::asio::async_read_until或boost::asio::async_write串口时。将串行端口声明为:boost::asio::serial_portmSerialPort;在这个错误之后,我尝试try{mSerialPort.cancel();mSerialPort.close();}catch(boost::system::system_errorerror){;}其中一个(尚不确定是哪个)挂起并

c++ - CMake 错误 : common is required but boost was not found

我正在尝试使用cmake_3.5.0编译opencv_2.4.9以在Qt_5.3.2MinGW中运行一个项目,但它一直显示此错误:Commonneededbutcan'tfindboost我选择“MinGWMakefiles”作为生成器并在配置窗口中“指定native编译器”。我定义了BOOST_ROOT环境变量,这是我的CmakeLists.txt:cmake_minimum_required(VERSION2.8FATAL_ERROR)SET(sampleNameMyApp)set(Boost_USE_STATIC_LIBSON)set(Boost_USE_STATICON)set

c++ - 从 boost::shared_ptr<string> 返回 C 字符串

我将一些C++代码包装在函数中,以便使C++方法在C中可用。C++API方法返回boost::shared_ptr通常的对象。我在C++中导出的函数如下所示:extern"C"constchar*Hazelcast_Map_get_int_string(Hazelcast_Client_t*hazelcastClient,constchar*mapName,intkey,char**errptr){IMapmap=hazelcastClient->client->getMap(mapName);boost::shared_ptrvalue=map.get(key);string*str

python - 为什么不能使用 std::ref 将对象传递到 Boost.Python 模块中?

环境:使用Python3.5编译的Boost1.61.0以下C++代码输出12:classA{public:intfunc(){return12;}};BOOST_PYTHON_MODULE(bridge){usingnamespaceboost::python;class_("A",no_init).def("func",&A::func);}intmain(){Aa;PyImport_AppendInittab("bridge",PyInit_bridge);Py_Initialize();usingnamespaceboost::python;dictdictMain=extra

c++ - 如何编写模式规则来分隔目标文件和源文件的位置?

假设我的目录结构如下:./Header./Srcs./makefile文件夹./Header/的内容是两个头文件:header1.h#ifndefHEADER1_H#defineHEADER1_H#includevoidfunc1();#endifheader2.h#ifndefHEADER2_H#defineHEADER2_H#includevoidfunc2();#endif在./Srcs/我有以下srcs:src1.c#includevoidfunc1(){printf("func1()\n");}src2.c#includevoidfunc2(){printf("func2()

c++ - 为什么 clang 输出对齐特定的东西

假设我有一个基本的c程序,我用clang编译它,如下所示:#include"stdio.h"intx=0x7FFFFFFF;intmain(void){printf("%d\n",x);}使用clang-emit-llvmtemp.c-fno-rtti-O3-S编译生成以下位码:;ModuleID='temp.c'targetdatalayout="e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"targettriple="i686-pc-linux-gnu"@x=globali322147483647,align4@.str=privateu

c++ - 在 extern C 中使用 _attribute__ ((nothrow)) 有意义吗?

我有一些从C++调用的C代码。header类似于以下内容:#ifndefCLibH#defineCLibH#ifdef__cplusplusextern"C"{#endif//CAPIvoidfoo(void);//...#ifdef__cplusplus}#endif#endif由于我已经在使用externC,添加nothrow编译器属性有什么好处吗?#ifndefCLibH#defineCLibH#ifdef__cplusplusextern"C"{#endif//CAPIvoidfoo(void)__attribute__((nothrow));//...#ifdef__cplu

c++ - 对 __isoc99_sscanf 的 undefined reference

我有一个使用sscanf的静态C库libex.a。库是使用-std=c99编译的我想在使用-std=c++11编译的某些C++代码中使用库函数,但出现以下错误:lib/libex.a(srcfile.o):Infunction`my_function':/srcpath/srcfile.c:215:undefinedreferenceto`__isoc99_sscanf'经过一番探索后,我发现sscanf由于向后兼容性黑客攻击而存在版本问题,因此重定向到__isoc99_sscanf,所以我怀疑这是不知何故问题的根源。但是,我检查了我的glibc版本,它看起来足够新,以至于其他地方建议